package io.github.talelin.latticy.dto.category;

import io.github.talelin.latticy.model.CategoryDO;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import javax.validation.constraints.*;
import java.io.Serializable;
import java.util.List;

/**
 * ClassName CategoryDTO
 * Description
 * Create by zcy
 * Date 2022-06-09
 */
@Data
@NoArgsConstructor
public class CategoryDTO implements Serializable {

    private static final long serialVersionUID = -4817961500875249016L;

    /**
     * id
     */
    private Integer id;

    /**
     * 父ID
     */
    @PositiveOrZero(message = "{category.parent-id}")
    private Integer parentId;

    /**
     * 品类名称
     */
    @NotBlank(message = "{category.category-name}")
    private String categoryName;

    /**
     * 品类英文名称
     */
    @NotBlank(message = "{category.category-english-name}")
    private String categoryEnglishName;

    /**
     * 等级
     */
    @Positive(message = "{category.level}")
    @Min(value = 1, message = "{category.level-min}")
    @Max(value = 3, message = "{category.level-max}")
    private Integer level;


    private List<CategoryDTO> children;

    public CategoryDTO(CategoryDO categoryDO) {
        BeanUtils.copyProperties(categoryDO, this);
    }

}
